<!DOCTYPE html>
<html>
<head>
	<title>HOWTO Internet</title>
	<meta charset="utf-8">
	<link href="./manual.css" rel="stylesheet" type="text/css">
</head>
<body>
	<div id="container">

		<header class="logo-header">
			<img class="header-logo" alt="Logo" src="puppylogo96.png">
			<h1>HOWTO: Internet access by modem</h1>
		</header>
		<section>
			<h2>Dialup by analog modem</h2>
			<p>
				I originally designed Puppy to access the Internet by conventional modem dialup to an ISP (Internet Service Provider), over the Public Switched Telephone Network (PSTN). The modem is called an <i>analog modem</i>, as it sends and receives data by audible-frequency tones -- which you can hear as the modem dials the ISP.
			</p>
			<p>
				I have moved on to various modes of digital broadband access, however many people, in certain parts of the world, are still on analog dialup. Therefore, this section is still very relevant!
			</p>
			<p>
				Traditionally, Linux only really worked with what we call "hardware" serial modems -- whereas many modems are what is called "soft" modems, only sold with drivers for Microsoft Windows. If your PC has an internal modem, or a external modem attached via a USB cable, it is most likely a soft-modem.
				<br>
				Please note that I am describing analog modems here, for dialing-up an ISP (Internet Service Provider) -- these are different from 3G, ADSL and cable modems that are used for broadband digital Internet access.
				<ul>
					<li>
						<b>External serial modem</b>. If you have an external serial modem, it is easy to recognise by the distinctive cable -- fairly large flat rectangle shape, with 9 or 25 pins. This is a hardware modem, and will definitely work with Puppy.
					</li>
					<li>
						<b>Internal PCI modem card</b>. 'PCI' refers to the sockets on the motherboard, into which an internal modem can be plugged. Up until about 2002, true hardware PCI modems were manufactured, since then they have all been soft-modems -- so that's most likely what you have.
					</li>
					<li>
						<b>Modem built-in to the motherboard</b>. Technically, these are still PCI modems, as the term "PCI" actually refers to the main interface bus on the motherboard, to which all input/output devices are connected. These are all soft-modems.
					</li>
					<li>
						<b>External USB modem</b>. These days USB is used for almost all external devices -- mouse, keyboard, modem, printer, scanner. There are some true-hardware USB modems, but most likely it is a soft-modem.</li>
					<li>
						<b>PCMCIA modem</b>. Also known as cardbus. This is a socket on laptops. These can be soft or hard, the modern ones likely to be soft.
					</li>
				</ul>
				What is a soft-modem? Basically, it is a cheaper modem that does less processing within itself and makes the CPU do some of the processing work. This means that it places an overhead on the CPU, that you won't notice with modern fast CPUs, but it is a factor for old PCs. My personal experience also is that hardware modems tend to have higher transfer speed even with modern PCs.
			</p>
			<p>
				The real down-side of a soft-modem however, is that to make the CPU do some of the processing work requires a special driver for that particular modem, and most manufacturers have only bothered to write drivers for Windows. However, some manufacturers have become more "Linux aware" and also some Linux enthusiasts have developed drivers.
			</p>
			<p>
				Be warned, if you have a soft modem, it may not work with Puppy. Puppy-enthusiast 'ezeze5000' (forum name) sent me half-a-dozen old PCI soft-modem cards to test. That was in 2008, and at that time I only got one of them to work in Puppy. Since then, the success-ratio has improved, and in 2010 I have got half of them to work.
			</p>
			<p>
				Note, if a soft-modem does work in Linux, there is a jargon name used for it -- it is called a "linmodem".
			</p>
			<section>
				<h3>How to dialup</h3>
				<p>
					In a nutshell, Puppy will auto-detect your analog modem, and if it is a supported type then everything will be ready to connect. For serial modems this is straightforward, however Puppy now supports many soft-modems. If it's supported, it will most likely be autodetected.
				</p>
				<p>
					Note: autodetection and auto-setup of some modems is a work-in-progress, and there is some on-going discussion on this topic in the Puppy forum.
				</p>
				<p>
					To dialup, all you have to do is click the 'connect' icon on the desktop. This will bring up the "Internet Connection Wizard" in which you will see a a button labelled "Internet by dialup analog or wireless modem" -- just click that and you're in business -- a program I developed called <i>PupDial</i> runs, and it will tell you whether or not your modem is detected.
				</p>
				<p>
					Note, in the Internet Connection Wizard you will see some radio-buttons at the bottom. These enable you to configure the desktop 'connect' icon to immediately launch PupDial, not the Wizard -- one less click to get online!
				</p>
				<p>
					One thing though, although Puppy can autodetect many modems and automatically set things up so that the modem is ready to go, in some cases you may have to do some extra tweaking. For example, Puppy detects your modem, but it won't dialout -- you do some research and find that the modem "initialisation string" needs to be changed, then it works. Whatever, if you do tweak a soft-modem and get it going, please please let me know about it and I can build those tweaks into the next release of Puppy.<br>
					Example: some soft modems need the "dialtone check" in PupDial to be turned off.
				</p>
			</section>
			<section>
				<h3>Further useful information</h3>
				<p>
					If you need to troubleshoot your dialup modem, I recommend browse around on the Puppy Forum. There is a special section on dialup modems, with lots of feedback and solutions.
				</p>
				<p>
					The main guy who can help is forum member 'rerwin', who is currently working toward getting modems to be autodetected and automatically setup. Rerwin is also updating PupDial.
				</p>
				<p>
					If for some reason PupDial does not work for you, Puppy has two other modem dialer programs, called <i>Gkdial</i> and <i>Xeznet</i>, that are PET packages that you can install (see 'install' icon on desktop) -- be warned though that the former is a GTK1 application, the latter a Tcl/Tk application and in the case of Puppy 4.x and later these are dependencies that will also have to be installed (although 4.20 and 4.21 does have Tcl/Tk, 4.3 and later does not) -- so stay with PupDial if at all possible. Note on Xeznet: when adding an account, the "tty" field and the "speed" field do not need to have anything entered into them as they default to /dev/modem and 115200bps.
				</p>
				<p>
					If you would like to experiment with sending Hayes commands to your modem, Puppy has a neat little commandline program called <i>modem-stats</i>. Open a terminal window and run it like this:
					<code># modem-stats -c "ATZ" /dev/ttyS0</code>
					This has a local <a href="modem-stats.htm">help file</a>. Puppy also has another tiny commandline serial-port communications utility called <i>picocom</i>. Online help for picocom: <a href="http://linux.die.net/man/8/picocom">http://linux.die.net/man/8/picocom</a>.
				</p>
				<p>
					There is another application, called <i>Cutecom</i>, a GUI serial port terminal program, that you will find in the Utility menu (note, recent releases of Puppy do not have this program builtin -- it is a PET package: see the menu Setup --&gt; Puppy Package Manager, or click the 'install' icon on the desktop -- it requires the Qt library package, which get automatically installed). It's very easy to use: for my modem I had to tick the "Handshake: software" checkbox and selected "CR,LF line end" from the listbox near bottom of the window. After opening the serial port for any Hayes commands that you type in "Input:" box, the response from the modem will appear in the top text box. For example, you type "AT" followed by the ENTER key, and the modem should respond with "OK".
				</p>
				<p>
					This site has more info on soft-modems: <a href="http://linmodems.technion.ac.il/resources.html">linmodems.technion.ac.il/resources.html </a>
				</p>
				<p>
					Here are some URLs with lists of modem strings for particular modems:
				</p>
				<p><a href="http://www.56k.com/inits/">www.56k.com/inits</a></p>
				<p><a href="http://www.west.net/%7Ejay/modem/">www.west.net/~jay/modem</a></p>
			</section>
		</section>
		<section>
			<h2>'Dialup' by wireless modem</h2>
			<p>
				Wireless modems are often referred to as 3G modems or HSDPA modems. In a nutshell, they give you Internet access without needing wiring. They also require a "dialup" operation similar to analog modems, so in Puppy we are able to use the same PupDial GUI tool for both.
			</p>
			<p>
				However, there are many different technologies used for these modems, other than 3G or HSDPA, such as GPRS, the main difference from the user point of view being data transfer speed. Basically, the order of increasing speed is GPRS, 3G, HSDPA.
			</p>
			<p>
				I have only just started to write this section (as at December 2010), based on my experience with three different 3G modems. I present some notes on these that you might find useful. I live in Australia, so these notes will be particularly useful for other Aussies.
				<table>
					<tbody>
					<tr>
						<td>Vodafone<br>
						</td>
						<td>Access number: *99#<br>
			APN: vfprepaymbb<br>
						</td>
					</tr>
					<tr>
						<td>Optus Huwaei E160-E<br>
						</td>
						<td>Access number: *99#<br>
			APN: preconnect<br>
						</td>
					</tr>
					<tr>
						<td>Telstra<br>
						</td>
						<td>Access number: *99#<br>
			APN: telstra.internet<br>
						</td>
					</tr>
					</tbody>
				</table>
				In PupDial, fill in the 'Access number' and 'APN' fields. The 'Username' and 'Password' fields do not matter, so leave them as they are -- <b>do not set them to empty</b> as the wvdial executable objects. Usually, everything else can be left as-is, and you just click the 'Connect' button.
			</p>
			<p>
				if you live in Australia, this page is particularly useful. It has APN's for all the 3G vendors:<br>
				<a href="http://www.unlockguru.com/2011/06/australia-3g-apn-setting/">http://www.unlockguru.com/2011/06/australia-3g-apn-setting/</a>
			</p>
			<p>
				When PupDial is started and a new/changed modem is detected, PupDial tests that the modem responds and tries to determine a suitable "initialization string" -- these are commands that are sent to the modem, known as Hayes Commands. These are also used for analog modems, but with some extensions. This wikipedia page is a good introduction, and also outlines the 3G/GSM modem extensions:
			</p>
			<p>
				<a href="http://en.wikipedia.org/wiki/Hayes_command_set">http://en.wikipedia.org/wiki/Hayes_command_set</a> <br>
			</p>
			<p>
				It may be that PupDial does not get the initialization string quite right for your modem. In that case, if you are able to find an alternate string that does work, let me know.
			</p>
			<p>
				Here is various information that users have sent me, or that I have found:
				<table>
					<tbody>
					<tr>
						<td>Huawei E1550 3G USB modem</td>
						<td>
							Puppy Forum members 'zygo' and 'pakt' reported the default string did not work (<a href="http://murga-linux.com/puppy/viewtopic.php?t=62891&amp;start=15">1</a> <a href="http://murga-linux.com/puppy/viewtopic.php?t=62891&amp;start=30">2</a>), but this did:
							<code>AT &amp;FE0 V1 X1 &amp;D2 &amp;C1 S0=0 </code>
							Update: It seems that there is a problem with re-plugging this modem. Just plug it in once, and the default string generated by PupDial should work. It has also been found best to plug the modem in after bootup.
						</td>
					</tr>
					<tr>
						<td>Huawei E160-E 3G USB modem</td>
						<td>
							This modem is interesting as it does not require a modeswitch. It is permanently in both storage and modem modes. Thus, when you plug it in you will see a optical-disc icon appear on the desktop, but it simultaneously works as a modem (at port /dev/ttyUSB0).<br>
							I would like feedback on any other modems that work this way, as I can make an entry for it in /etc/udev/rules.d/52-usb_modem_puppy.rules, to popup detection windows when the modem is plugged in.
						</td>
					</tr>
					</tbody>
				</table>
			</p>
			<section>
				<h3>Further hints/advice</h3>
				<ul>
					<li>
						You might get the best/consistent results if you <b>plug the modem in after bootup</b>. In theory, if the modem is already plugged-in at bootup it should still work, but some feedback reports inconsistent behaviour in this situation.
					</li>
					<li>
						Some 3G modems do not need to be mode-switched. It may be that they got switched once and then remain permanently switched. You may get the situation where an optical-disc icon appears on the desktop when you plug-in the modem, but it still works as a modem -- meaning that it is simultaneously in both modes.
					</li>
					<li>
						Setup in Windows first. I hate to recommend this, but if you have acess to a Windows system, plug-in your brand-new modem and get connected to the network with Windows. This may avoid some setup hassles. After that you can use the modem with Linux. I would like feedback on experiences with not using Windows at all, especially success stories!
					</li>
				</ul>
			</section>
		</section>
		<section>
			<h2>Technical information</h2>
			<p>
				These are some notes for those who want to understand how Puppy is doing things "under the hood". Users don't need to know this stuff.
			</p>
			<p>
				There are two types of modems, from the point of view of detection in Puppy: internal (fixed) or external (hotpluggable, or removable). The internal modems are detected when Puppy boots, the removable may be detected at bootup but also if the modem is plugged in after bootup.
			</p>
			<p>
				At bootup, the script /etc/rc.d/rc.sysinit causes the correct drivers (modules) to load for detected hardware. If you look in rc.sysinit, you will see an important line of code:
				<code>echo add &gt; ${ONEPATH}/uevent #generates an 'add' uevent.</code>
				This tells the kernel to generate what is called a 'uevent' for a detected item of hardware. There is a daemon program, 'udevd' that reads these uevents and in accordance with rules in /etc/udev/rules.d and /lib/udev/rules.d, causes the appropriate driver, firmware (etc.) to load/install.
			</p>
			<p>
				The most important udev rules file is /etc/udev/rules.d/50-udev-puppy-basic.rules, which has these two lines in it:<br>
				<code>
					# kernel firmware loader<br>
					SUBSYSTEM=="firmware", ACTION=="add", RUN+="/sbin/pup_event_backend_firmware"<br>
					# Module autoloading<br>
					ACTION=="add", SUBSYSTEM=="?*", ENV{MODALIAS}=="?*", RUN+="/sbin/pup_event_backend_modprobe"
				</code>
				The two scripts 'pup_event_backend_firmware' and 'pup_event_backend_modprobe' take care of driver and firmware loading. Firmware are data files needed by some drivers, and these are kept in /lib/firmware.
			</p>
			<p>
				All of Puppy's hardware detection and module loading is developed especially for Puppy and is different from all other Linux distributions. The firmware also (plus any other data files or executables) required by a driver, may not initially be in /lib/firmware, but in a 'firmware tarball' kept in /lib/modules/all-firmware -- pup_event_backend_modprobe takes care of expanding the appropriate firmware tarballs.
			</p>
			<p>
				An important point to note is that wireless modems are often hybrid, or dual-personality devices. My 3G USB modems have two personalites -- they can behave either as a storage device or a modem. In most cases, when first plugged in, they are in storage mode and will not work as a modem. They have to be switched to modem-mode, and we have a software program called 'usb-modeswitch' to do that...
			</p>
			<section>
				<h3>usb-modeswitch</h3>
				<p>
					There are special udev rules that will trigger the usb-modeswitch applicatiuon, /lib/udev/rules.d/40-usb_modeswitch.rules and /etc/udev/rules.d/41-usb_modeswitch-puppy.rules.
				</p>
				<p>
					When you hotplug a USB modem, the usb-modeswitch should be triggered, and the modem will switch into modem-mode.
				</p>
				<p>
					The sequence is that a udev rule for a particular USB hardware causes /lib/udev/usb_modeswitch to run, which in turn launches both /usr/sbin/usb_modeswitch_dispatcher and /usr/sbin/usb_modeswitch_status.<br> The former will perform the actual switch to modem-mode and if required load a driver needed by that modem. The latter is written especially for Puppy and puts up status messages on-screen.
				</p>
				<p>
					In some cases usb-modeswitch does not get triggered, such as when the modem is already plugged in at bootup. In that case, when PupDial is run, it also runs /usr/sbin/pupdial_init_hotpluggable, which detects the correct hotplugged modem and will rerun the kernel uevents if necessary (which will trigger usb-modeswitch).
				</p>
			</section>
		</section>
		<footer class="legal">(c) Copyright Barry Kauler Dec. 2010</footer>
	</div>
</body>
</html>